#include "aboutview.h"
#include <QDebug>
#include <QMouseEvent>
#include <QGraphicsTextItem>

enum ABOUTPressType
{
    NULL_BTP,
    BACK_BTP
}APressTp(NULL_BTP);

AboutView::AboutView(QWidget *parent) :
    QGraphicsView(parent)
{
    m_Scene = new QGraphicsScene(this);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setScene(m_Scene);
    m_Scene->setSceneRect(0.0, 0.0, 640.0, 360.0);
    setGeometry(0.0,0.0,640.0,360.0);

    m_backItem = m_Scene->addPixmap(QPixmap(":/image/595.0.png","png"));
    m_backItem->setPos(570,0);
    m_backItem->setZValue(2.0);
}

AboutView::~AboutView()
{
    delete m_Scene;
}

void AboutView::mousePressEvent(QMouseEvent *event)
{
    if(m_backItem->isUnderMouse())
    {
        APressTp = BACK_BTP;
        m_backItem->setPixmap(QPixmap(":/image/2.png","png"));
    }
    else
    {
        APressTp = NULL_BTP;
    }
}

void AboutView::mouseReleaseEvent(QMouseEvent *event)
{
    switch(APressTp)
    {
    case BACK_BTP:
    {
        m_backItem->setPixmap(QPixmap(":/image/595.0.png","png"));
        if(m_backItem->isUnderMouse())
        {
            emit back();
        }
    }
        break;
    default:
        break;
    }
}
